<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>


    <script>
        //数组

        // var arr = new Array(4);
        // arr[0] = 2;
        // arr[1] = 3;
        // arr[2] = 5;
        // arr[3] = 9;
        // console.log(arr)


        // var arr2 = [8, 9, 5, 6];

        //遍历
        // for (var i = 0; i < arr2.length; i++) {
        //     console.log(arr2[i]);
        // }

        // //增强for
        // for (var e in arr2) {
        //     //此处的e是下标
        //     console.log(arr2[e])

        // }

        // console.log(arr2)


        //数组的常用方法
        //1.length

        var arrs = [8, 9, 5, 6, 1, 4];
        // console.log(arrs.length) //6

        //2.join()
        // console.log(typeof(arrs.join("|")))

        // //3.splice(),有两个参数，第一个是下标，第而个是要删除的个数,会改变原数组的个数
        // var arr = arrs.splice(1, 3);
        // console.log(arr) //9,5,6
        // console.log(arrs)

        //4.sort()

        // function desc(a, b) {
        //     return b - a;
        // // }
        // var desc = (a, b) => b - a;
        // console.log(arrs.sort(desc)) //默认是从小到大
        //     //我想倒序输出

        //5.push()
        // arrs.push(33, 33, 33)
        // console.log(arrs)

        // //6.unshift
        // arrs.unshift(88, 78, 88)
        // console.log(arrs)

        //pop()/shift()
        console.log(arrs.pop())
        console.log(arrs.shift())
    </script>
</body>

</html>